package com.example.service.ServiceImpl;

import com.example.entity.Equipment;
import com.example.mapper.EquipmentMapper;
import com.example.service.EquipmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EquipmentServiceImpl implements EquipmentService {

    @Resource
    EquipmentMapper mapper;

    @Override
    public PageInfo<Equipment> queryEquipment(Integer pageNum, Integer PageSize) {
        //开启分页
        PageHelper.startPage(pageNum, PageSize);
        List<Equipment> equipment = mapper.queryEquipment();
        return new PageInfo<>(equipment);
    }

    @Override
    public List<Equipment> selectTime() {
        return mapper.selectTime();
    }


    @Override
    public List<Equipment> selectEquipment(int equipmentId) {
        return mapper.selectEquipment(String.valueOf(equipmentId));
    }


    @Override
    public void addEquipment(String equipmentName, String equipmentState, String equipmentCharges) {
        mapper.addEquipment(equipmentName, equipmentState, equipmentCharges);
    }

    @Override
    public void deleteEquipment(int equipmentId) {
        mapper.deleteEquipment(equipmentId);
    }

    @Override
    public int repairEquipment(int equipmentId) {
        return mapper.repairEquipment(String.valueOf(equipmentId));
    }

    @Override
    public int rentEquipment(int equipmentId) {
        return mapper.rentEquipment(String.valueOf(equipmentId));
    }

    @Override
    public int recoveryEquipment(int equipmentId) {
        return mapper.recoveryEquipment(String.valueOf(equipmentId));
    }

    @Override
    public List<Equipment> chargeEquipment(int equipmentId) {
        return mapper.chargeEquipment(String.valueOf(equipmentId));
    }

}
